﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLogic;

namespace SI
{
    public partial class Defaul : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            GetUserCommand cmd = new GetUserCommand(txtUserName.Text, txtPassweord.Text);
            cmd.Execute();

            if (cmd.Result == null)
            {
                lblWrongPassword.Visible = true;
            }
            else
            {   //Property: CurrentUser in BasePage
                Session["CurrentUser"] = cmd.Result;
                if (cmd.Result.user_role == "dealer")
                {
                    Response.Redirect("SearchSaleAdvance.aspx");
                }
                else if (cmd.Result.user_role == "ro")
                {
                    Response.Redirect("ROSearch.aspx");
                }
                else //TMT
                {
                    Response.Redirect("TMTSearch.aspx");
                }
            }

        }
    }
}